// <copyright file="HtmlTableDataSource.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System.Globalization;
using System.Text;
using YUIAspNet.Common;

namespace YUIAspNet
{
    /// <summary>
    /// Represents a table data source.
    /// </summary>
    public class HtmlTableDataSource : DataSourceBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlTableDataSource"/> class.
        /// </summary>
        public HtmlTableDataSource() : base(DataSourceType.HtmlTable) 
        {
        }

        /// <summary>
        /// Gets or sets the element ID.
        /// </summary>
        /// <value>The element ID.</value>
        public string ElementID { get; set; }
        
        /// <summary>
        /// Adds the column.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        public void AddColumn(string columnName)
        {
            Keys.Add(columnName);
        }

        /// <summary>
        /// Serializes the specific properties foreach implementor.
        /// </summary>
        /// <returns></returns>
        protected override StringBuilder SerializeSpecificData()
        {
            if (string.IsNullOrEmpty(ElementID))
                throw new RequiredPropertyException("ElementID");

            return new StringBuilder().AppendFormat(CultureInfo.InvariantCulture, "\"ElementID\": \"{0}\"", ElementID);
        }
    }
}
